package com.qgs.waf.controller.zbks;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qgs.waf.model.Alertlog;
import com.qgs.waf.service.ZbksAlertlogService;
import com.qgs.waf.util.Result;
import com.qgs.waf.util.WebResult;

/**
 * 告警
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value = "/zbks/alc")
public class ZbksAlertLogController {
	private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd");
	@Autowired
	private ZbksAlertlogService as;

	@ResponseBody
	@RequestMapping(value = { "list" }, produces = "application/json; charset=utf-8")
	public String queryListByProvinceAndIndustry(@RequestParam(value = "pn", required = false, defaultValue = "1") int pn, @RequestParam(value = "ps", required = false, defaultValue = "10") int ps, @RequestParam(value = "start", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date start, @RequestParam(value = "end", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date end, @RequestParam(value = "province", required = false) String province, @RequestParam(value = "industry", required = false) String industry, @RequestParam(value = "industry", required = false) String status) {
		return as.queryListByProvinceAndIndustry(pn, ps, SDF.format(start), SDF.format(end), province, industry, status);
	}

	@ResponseBody
	@RequestMapping(value = { "add" })
	public String add(Alertlog al) {
		int res = as.saveAlertlog(al);
		if (res > 0) {
			return new WebResult<Integer>(res, Result.SUCCESS).toString();
		} else {
			return new WebResult<String>("0", Result.FAILURE).toString();
		}
	}

	@ResponseBody
	@RequestMapping(value = { "send" })
	public String send(Alertlog al) {
		int res = as.sendAlertLog(al);
		if (res > 0) {
			return new WebResult<Integer>(res, Result.SUCCESS).toString();
		} else {
			return new WebResult<String>("0", Result.FAILURE).toString();
		}
	}

}
